package com.example.yunifangdemo.activity;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.example.yunifangdemo.R;
import com.example.yunifangdemo.adapter.GuidePageAdapter;

import java.util.ArrayList;
import java.util.List;

public class GuideActivity extends AppCompatActivity {
    private Context mContext;
    private List<ImageView> imageViews;
    //导航页资源，图片数组
    private int [] images = new int []{R.drawable.guide_page_1,R.drawable.guide_page_2,R.drawable.guide_page_3};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        mContext = this;
        ViewPager vp_guide = (ViewPager) findViewById(R.id.vp_guide);
        //初始化导航页
        initImageView();
        GuidePageAdapter adapter = new GuidePageAdapter(mContext,imageViews);
        vp_guide.setAdapter(adapter);


    }

    private void initImageView() {
        imageViews = new ArrayList<>();
        for (int i = 0; i<images.length; i++){
            ImageView iv = new ImageView(GuideActivity.this);
            iv.setScaleType(ImageView.ScaleType.FIT_XY);
            iv.setImageResource(images[i]);
            //添加到集合
            imageViews.add(iv);
        }
    }
}
